Curator 框架与 Zookeeer 版本 适配

您所在的位置:网站首页 zk 版本 Curator 框架与 Zookeeer 版本 适配

Curator 框架与 Zookeeer 版本 适配

2024-07-12 09:28| 来源: 网络整理| 查看: 265

问题

在使用 curator 框架测试的时候,本地 idea 出现了如下问题

Exception in thread "main" org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /test1 at org.apache.zookeeper.KeeperException.create(KeeperException.java:106) at org.apache.zookeeper.KeeperException.create(KeeperException.java:54) at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1549) at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1180) at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1156) at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64) at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100) at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1153) at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:607) at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:597) at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:51) at com.kkarch.zookeeper.ZkTest.main(ZkTest.java:41)

并且看zookeeper 服务端日志出现了: Received packet at server of unknown type 15

一开始我以为是我安装的单机 Zookeeper 有问题,所以找了个集群安装的 Zookeeper 也是这种错。 后面去官网:Curator官网 看到了版本兼容模式的介绍:

ZooKeeper 3.4.x is now at end-of-life. Consequently, the latest versions of Curator have removed support for it. If you wish to use Curator with ZooKeeper 3.4.x you should pin to version 4.2.x of Curator. Curator 4.2.x supports ZooKeeper 3.4.x ensembles in a soft-compatibility mode. To use this mode you must exclude ZooKeeper when adding Curator to your dependency management tool.

说的是 Zookeeper 3.4.x 版本已经是最后一个版本,curator 最后一个版本也移除了对 3.4.x 的支持。 如果你想在 Zookeeper 3.4.x 中使用Curator ,可以选择 4.2.x 版本的 curator。 curator 4.2.x 版本和 zookeeper 3.4.x 版本会在兼容模式下运行。 为了使用这种模式,你必须在版本管理工具中移除对 Zookeeper 的依赖,并且重新添加对 Zookeeper 的依赖。

org.apache.curator curator-recipes 4.2.0 org.apache.zookeeper zookeeper org.apache.zookeeper zookeeper 3.4.14

改成这样就可以了。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3